<?php
	include "ip.php";
	include "useragent.php";
	$ip = "";
	$useragent = "";
	$content = "";
	//for($i=0;$i<3;$i++)
	//{
		$ip = $ips[rand(0,(count($ips)-1))];
		$useragent = $useragents[rand(0,(count($useragents)-1))];
		$content = getHtml($_REQUEST["url"],$ip,$useragent,$_REQUEST["referer"],$_REQUEST["cookie"]);
		if(!($content!="" && !strpos($content,"The document has moved")))
			@file_put_contents("result.txt",$ip."\r\n",FILE_APPEND);
		//{
		//	echo $content;
		//	return;
		//}
		//else
			//@file_put_contents("result.txt",$ip."\r\n",FILE_APPEND);
		echo $content;
	//} 
	function getHtml($url,$ip,$useragent,$referer,$cookie)
	{
		$ch = curl_init();
		$urls = str_replace(" ","%20",str_replace('\"','"',urldecode($url)));
		curl_setopt($ch, CURLOPT_URL, $urls);
		//curl_setopt($ch, CURLOPT_REFERER ,$urls);
		curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
		curl_setopt($ch, CURLOPT_TIMEOUT, 60);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_HTTPHEADER,array('Accept-Encoding: gzip, deflate'));
		curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
		//curl_setopt($ch, CURLOPT_INTERFACE, $ip);
		if(!empty($referer)){
			curl_setopt($ch, CURLOPT_REFERER, $referer);//模拟来路
		}
		else{
			curl_setopt($ch, CURLOPT_REFERER ,$urls);
		}
		if(!empty($cookie)){
			curl_setopt($ch, CURLOPT_COOKIE, $cookie);
		}
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
		//curl_setopt($ch, CURLOPT_HEADER, 1);
		if ($_SERVER['REQUEST_METHOD']=='POST')
			{
			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('php://input'));
			}
		$content = curl_exec($ch);
		//print_r(curl_error($ch));
		curl_close($ch);
		return $content;
	}
?>

